#include<bits/stdc++.h>
using namespace std;

vector<int> explorationSupply(vector<int>& station, vector<int>& pos)
{
    vector<int> ans;
    
    for(auto i:pos)
    {
        int index = lower_bound(station.begin(), station.end(), i)-station.begin();
        if(index == station.size())
            index--;
        if(index)
            ans.push_back(abs(i-station[index]) < abs(i-station[index-1]) ? index : index-1);
        else
            ans.push_back(0);
    }
    return ans;
}

int main()
{
	int n, m, x;

	cin>>n;

	vector<int> station, pos;

	for(int j = 1;j <= n;j++)
	{
		cin>>x;
		station.push_back(x);
	}
		
	cin>>m;
			
	for(int j = 1;j <= m;j++)
	{
		cin>>x;
		pos.push_back(x);
	}
		
	vector<int> ans = explorationSupply(station, pos);
	for(auto j:ans)
		cout<<j<<" ";
	return 0;
}

